package com.yuexunit.operationman.nbsy.module.Login.presenter.impl;

import com.yuexunit.operationman.nbsy.module.Login.bean.PatientListBean;
import com.yuexunit.operationman.nbsy.module.Login.model.IPatientListModel;
import com.yuexunit.operationman.nbsy.module.Login.presenter.IPatientListPresenter;
import com.yuexunit.operationman.nbsy.module.Login.ui.view.IPatientListView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action0;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/10/24 0024.
 */

public class PatientListPresenter implements IPatientListPresenter{

    private IPatientListModel mModel;
    private IPatientListView mView;

    public PatientListPresenter(IPatientListView view,IPatientListModel model){
        mModel=model;
        mView=view;
    }


    @Override
    public void getPatientListData(Map<String, String> praise) {
        mModel.getPatientListData(praise)
                .subscribeOn(Schedulers.io())
                .doOnSubscribe(new Action0() {
                    @Override
                    public void call() {

                    }
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<PatientListBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast(e.getMessage());
                    }

                    @Override
                    public void onNext(PatientListBean patientListBean) {
                        mView.getPatientListData(patientListBean);
                    }
                });
    }
}
